package Controller.GoodsCategory;


import Service.GoodsCategoryService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "deleteGoodsCategory", value = "/deleteGoodsCategory")
public class DeleteGoodsCategory extends HttpServlet {
    GoodsCategoryService goodsCategoryService = new GoodsCategoryService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer id = Integer.valueOf(request.getParameter("id"));
        try {
            goodsCategoryService.deleteCategory(id);
            request.getRequestDispatcher("/ListGoodsCategory").forward(request,response);
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}